package com.huadao.cart_ccs.data.bo;

import com.huadao.cart_ccs.R;
import com.huadao.cart_ccs.main.CartApplication;

/**
 *串口
 */
public class SerialPortBO extends BaseBO {
    private byte status;

    public static final byte ModularType_SerialPort=0x07;
    public static final byte serialPort_NO1 = 0x01;

//    public static final byte liquidLevelMeter = 0x09;//液位仪
    public static final byte read= (byte) 0xFF;//读

    public static final byte bothError= (byte) 0x00;//0代表两个都异常；
    public static final byte onlyDoorOk= (byte) 001;//1代表只有门正常；
    public static final byte onlyLiquidLevelOk= (byte) 0x02;//2代表只有液位正常；
    public static final byte bothOk= (byte) 0x03;//3代表都正常

    public byte getStatus() {
        return status;
    }

    public void setStatus(byte status) {
        this.status = status;
    }

    @Override
    protected String getOrderStr() {
        String orderStr = null;
        if (order == read) {
            orderStr = CartApplication.getInstance().getString(R.string.read);
        }
        return orderStr;
    }

    @Override
    protected String getOrderContentStr() {
        String statusSrt = null;
        if (status == bothError) {
            statusSrt = CartApplication.getInstance().getString(R.string.bothError);
        } else if (status == onlyDoorOk) {
            statusSrt = CartApplication.getInstance().getString(R.string.onlyDoorOk);
        } else if (status == onlyLiquidLevelOk) {
            statusSrt = CartApplication.getInstance().getString(R.string.onlyLiquidLevelOk);
        } else if (status == bothOk) {
            statusSrt = CartApplication.getInstance().getString(R.string.bothOk);
        }

        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("状态:");
        stringBuilder.append(statusSrt);
        return stringBuilder.toString();
    }

    public String getSattusStr(){
        return getOrderContentStr();
    }

    public static String getLiquidStatus(byte status){
        String statusSrt = "未知";
        if (status == bothError) {
            statusSrt = "异常";
        } else if (status == onlyDoorOk) {
            statusSrt = "异常";
        } else if (status == onlyLiquidLevelOk) {
            statusSrt = "正常";
        } else if (status == bothOk) {
            statusSrt = "正常";
        }
        return statusSrt;
    }
}
